<!DOCTYPE html>
<html lang="en" style="background:#fff;">
<head>
	<base href="${basePath}">
	<#include "common/top.html"/>
</head>
<body style="background:#fff;overflow: hidden">

<form class="layui-form" modelAttribute="role" name="form1" id="form1"  method="post" style="margin-left: 19px;margin-top: 41px;">
	<div class="layui-form-item layui-form-item-dialog">
		<label class="layui-form-label">用户名：</label>
		<div class="layui-input-inline">
			<input class="layui-input" type="text" readonly value="${emp.comUserName}"/>
		</div>
	</div>
	<div class="layui-form-item layui-form-item-dialog">
		<label class="layui-form-label"><span style="color: red;">*</span>旧密码：</label>
		<div class="layui-input-inline">
			<input class="layui-input" type="password" name="oldPassWord" id="oldPassWord" autofocus placeholder="请输入旧密码"/>
		</div>
	</div>
	<div class="layui-form-item layui-form-item-dialog">
		<label class="layui-form-label"><span style="color: red;">*</span>新密码：</label>
		<div class="layui-input-inline">
			<input class="layui-input" type="password" name="passWord" id="passWord" placeholder="请输入新密码"/>
		</div>
	</div>
	<div class="layui-form-item layui-form-item-dialog">
		<label class="layui-form-label"><span style="color: red;">*</span>确认密码：</label>
		<div class="layui-input-inline">
			<input class="layui-input" type="password" name="chkpwd" id="chkpwd" placeholder="请输入确认密码"/>
		</div>
	</div>

</form>
</body>
<script type="text/javascript" charset="utf-8"  src="${basePath}static/js/DES3.js"></script>
<script type="text/javascript">
    layui.use(['form'], function () {
        form = layui.form();
        form.render();
    });
	//保存
	function save(){
		if(
            checkIsNull("oldPassWord","请输入旧密码！")||checkIsNull("passWord","请输入新密码！")||
			checkIsNull("chkpwd","输入确认密码！")
		){
			return;
		}

		if($("#passWord").val()!=$("#chkpwd").val()){
			$("#chkpwd").tips({
				side:3,
	            msg:'两次密码不相同',
	            bg:'#fe5d6f',
	            time:2
	        });
			$("#form1 input:not(:first)").val("");
			$("#oldPassWord").focus();
			return false;
		}
        var reg = /^(?=.*[a-zA-Z])(?=.*\d)(?=.*[~!@#$%^&*()_+`\-={}:";'<>?,.\/]).{4,16}$/;
        var flag = reg.test($("#passWord").val());
        if(flag == false){
            $("#passWord").tips({
                side:3,
                msg:'新密码必须由 4-16位字母、数字、特殊符号线组成',
                bg:'#fe5d6f',
                time:2
            });
            $("#form1 input:not(:first)").val("");
            $("#oldPassWord").focus();
            //alert("新密码必须由 4-16位字母、数字、特殊符号线组成.");
            return false;
        }

        $('#oldPassWord').val( DES3.encrypt("x1234g6789abcd012345w789",$('#oldPassWord').val()));
        $('#passWord').val( DES3.encrypt("x1234g6789abcd012345w789",$('#passWord').val()));
        $('#chkpwd').val( DES3.encrypt("x1234g6789abcd012345w789",$('#chkpwd').val()));
        $.ajax({
			url: '${basePath}sysuser/user/updataPassWord',
			data: $("#form1").serialize(),
			type: "POST",
			success: function(data){
				if (data.status == 'success') {
                    parent.layer.alert(data.msg,function(index){
                        var index1 = parent.layer.getFrameIndex(window.name); //获取窗口索引
                        parent.layer.close(index1);
                        parent.layer.close(index);
                    });
				}else{
					parent.layer.alert(data.msg);
                    $("#form1 input:not(:first)").val("");
                    $("#oldPassWord").focus();
				}
        	}
        });
    }

</script>
</body>
</html>